<?php
  class PlaceService{
  	function getPlaceLayer($uid, $provinceAccessId, $districtAccessId, $tambonAccessId, $selectTambon, $selectMoo, $selectUnit){
			//return type 
			$objectArray[0]['tambon_id'] = $selectTambon;
			$objectArray[0]['moo'] = $selectMoo;
			$objectArray[0]['unit'] = $selectUnit;									
			$objectArray[0]['type'] = 1;
			return $objectArray;					
  	}
  	
  	function arrayToXML($uid, $provinceAccessId, $districtAccessId, $tambonAccessId, $objectArray, $selectTambon, $selectMoo, $selectUnit){
			$accessArray['province_access'] = implode(",", $provinceAccessId);
			$accessArray['district_access'] = implode(",", $districtAccessId);
			$accessArray['tambon_access'] = implode(",", $tambonAccessId);    
    		
  	//Sample $home_nextxml
	  //http://localhost/zk128/index.php?module=VoteDataCenter&type=service&func=home&province=84&district=8404&tambon=840401,840402,840403,840404,840405,840406&uid=2&st=840406&sm=1&su=1 			  		
  		$home_nextxml = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."?module=VoteDataCenter&amp;type=service&amp;func=home&amp;province=".$accessArray['province_access']."&amp;district=".$accessArray['district_access']."&amp;tambon=".$accessArray['tambon_access']."&amp;uid=".$uid."&amp;st=".$selectTambon."&amp;sm=".$selectMoo."&amp;su=".$selectUnit;  			

  	//Sample $person_nextxml
	  //http://localhost/zk128/index.php?module=VoteDataCenter&type=service&func=person&province=84&district=8404&tambon=840401,840402,840403,840404,840405,840406&uid=2&st=840406&sm=1&su=1 		
      $person_nextxml = "http://".$_SERVER['SERVER_NAME'].$_SERVER['PHP_SELF']."?module=VoteDataCenter&amp;type=service&amp;func=person&amp;province=".$accessArray['province_access']."&amp;district=".$accessArray['district_access']."&amp;tambon=".$accessArray['tambon_access']."&amp;uid=".$uid."&amp;st=".$selectTambon."&amp;sm=".$selectMoo."&amp;su=".$selectUnit;  			
  		
      $placeId1 = "pl".$selectTambon.$selectMoo.$selectUnit.$objectArray[0]['type'];
   
      

      
      $xml = new DOMDocument('1.0', 'UTF-8');
      $xml->formatOutput = true;

      $xml_node_datas = $xml->createElement("datas");
      $xml->appendChild( $xml_node_datas );
        $xml_node_data = $xml->createElement("data");
        $xml_node_datas->appendChild( $xml_node_data );
        $xml_node_data->setAttribute("id", $placeId1);
          $xml_node_title = $xml->createElement("title","ข้อมูลบ้าน");
          $xml_node_data->appendChild( $xml_node_title );
          $xml_node_description = $xml->createElement("description","ข้อมูลบ้าน");
          $xml_node_data->appendChild( $xml_node_description );
          $xml_node_logo = $xml->createElement("logo",'http://'.$_SERVER["SERVER_NAME"].'/modules/VoteDataCenter/pnimages/house.png');
          $xml_node_data->appendChild( $xml_node_logo );
          $xml_node_type = $xml->createElement("type","home");
          $xml_node_data->appendChild( $xml_node_type );
          $xml_node_publisher = $xml->createElement("publisher","publisher");
          $xml_node_data->appendChild( $xml_node_publisher );
          $xml_node_xmlpath = $xml->createElement("xmlpath",$home_nextxml);
          $xml_node_data->appendChild( $xml_node_xmlpath );
          $xml_node_xmlupdate = $xml->createElement("xmlupdate","PlaceUpdate.xml");
          $xml_node_data->appendChild( $xml_node_xmlupdate );
          $xml_node_date = $xml->createElement("date","2010-11-11 20:26:56");
          $xml_node_data->appendChild( $xml_node_date );
  

      return $xml;
  	
  	}

  	function setResponseNoData(){
  
     echo '<?xml version="1.0" encoding="UTF-8"?>
            <datas>
              <data id="0">
                <title></title>
                <description></description>
                <logo>http://localhost/gthai/911thai.png</logo>
                <type>home</type>
                <publisher>publisher</publisher>
                <xmlpath>home.xml</xmlpath>
                <xmlupdate>update.xml</xmlupdate>
                <version>1</version>
                <date>2010-11-08 20:26:56</date>
              </data>
            </datas>';
      pnShutDown();
  	}

  	
  	function renderXMLResponse($xmlObject){
      echo $xmlObject->saveXML();
  	}
  		      				        	
  	function saveXMLResponse($xmlDirectoryPath, $xmlFileName, $xmlObject){      
      $xmlObject->save($xmlDirectoryPath.$xmlFileName);	
  	}  
  	
  }
?>